#!/bin/bash
# this is the postinstall script for the packaging stage
#
# openQRM Enterprise developed by openQRM Enterprise GmbH.
#
# All source code and content (c) Copyright 2014, openQRM Enterprise GmbH unless specifically noted otherwise.
#
# This source code is released under the GNU General Public License version 2, unless otherwise agreed with openQRM Enterprise GmbH.
# The latest version of this license can be found here: src/doc/LICENSE.txt
#
# By using this software, you acknowledge having read this license and agree to be bound thereby.
#
#           http://openqrm-enterprise.com
#
# Copyright 2014, openQRM Enterprise GmbH <info@openqrm-enterprise.com>
#

# is this an update ?
if [ -f "/usr/share/openqrm_pre_update/etc/openqrm-server.conf" ]; then
	if [ -x "/etc/init.d/openqrm" ]; then
		/etc/init.d/openqrm stop || echo
	fi
	if [ -x "/usr/share/openqrm/bin/openqrm-update" ]; then
		/usr/share/openqrm/bin/openqrm-update base -f
		/usr/share/openqrm/bin/openqrm-update post -f
		/usr/share/openqrm/bin/openqrm-update initrds -f
	fi
	# save state
	touch /usr/share/openqrm/package-update.state
fi
# add openqrm init
chmod +x /usr/share/openqrm/etc/init.d/openqrm
ln -sf /usr/share/openqrm/etc/init.d/openqrm /etc/init.d/openqrm
/etc/init.d/openqrm start


